﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;

namespace cms.libs
{
    public class Users
    {
        private DBHelper db = null;

        public Users()
        {
            db = new DBHelper(Config.SQLConn);
        }

        public int ID
        {
            get;
            set;
        }

        public string Name
        {
            get;
            set;
        }

        public string Password
        {
            get;
            set;
        }

        public string FullName
        {
            get;
            set;
        }

        public string Address
        {
            get;
            set;
        }

        public string Email
        {
            get;
            set;
        }

        public string Telephone
        {
            get;
            set;
        }

        public int Gender
        {
            get;
            set;
        }

        public string Comments
        {
            get;
            set;
        }

        public DateTime DateBirth
        {
            get;
            set;
        }

        public DateTime LastLogon
        {
            get;
            set;
        }

        public string SessionID
        {
            get;
            set;
        }

        public int Status
        {
            get;
            set;
        }

        public string Passwordmatrix
        {
            get;
            set;
        }


        public Users GetbyUserName(string UserName)
        {
            SqlCommand oCommand = new SqlCommand("sp_User_GetForUserName");
            oCommand.CommandType = CommandType.StoredProcedure;
            oCommand.Parameters.Add(new SqlParameter("@UserName", UserName));
            List<Users> lRet = db.GetList<Users>(oCommand);
            if (lRet == null || lRet.Count == 0)
                return null;
            return lRet[0];
        }

    }
}
